﻿using System.IO;

namespace OpenLS.Spreadsheet.Formats.Biff.Records
{
    internal class LbsDropData
    {
        private ushort _cLine;
        private ushort _dxMin;
        private bool _fFiltered;
        private XLUnicodeString _str;
        private bool _unused1;
        private byte _unused3;
        private byte _wStyle;

        public void Read(BinaryReader reader)
        {
            ushort abCunused2 = reader.ReadUInt16();
            _wStyle = (byte)(abCunused2 & 0x3);
            _unused1 = (abCunused2 & 0x4) != 0;
            _fFiltered = (abCunused2 & 0x8) != 0;
            _cLine = reader.ReadUInt16();
            _dxMin = reader.ReadUInt16();
            _str = new XLUnicodeString();
            _str.Read(reader);
            _unused3 = reader.ReadByte();
        }

        public void Write(BinaryWriter writer)
        {
            ushort ABCunused2 = _wStyle;
            if (_unused1) ABCunused2 |= 0x4;
            if (_fFiltered) ABCunused2 |= 0x8;
            writer.Write(ABCunused2);
            writer.Write(_cLine);
            writer.Write(_dxMin);
            _str.Write(writer);
            writer.Write(_unused3);
        }
    }
}